<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改</title>
</head>
<body>
<div>
  <h1>修改商品信息</h1>
  <input type="text" v-model="product.id" placeholder="id" readonly>
  <input type="text" v-model="product.title" placeholder="标题">
  <input type="text" v-model="product.price" placeholder="价格">
  <input type="text" v-model="product.saleCount" placeholder="销量">
  <input type="button" value="修改" @click="updatePro()">
</div>

<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>

<script>
  let v = new Vue({
    el:"div",
    data:{
      product:{}
    },
    created: function (){
      let id = location.search.split("=")[1];
      axios.get("/selectById?id="+id).then(function (response){
        v.product = response.data;
      })
    },
    methods:{
      updatePro(){
        axios.post("/updatePro",v.product).then(function (){
          alert("修改成功!");
          location.href="/product.html";
        })
      }
    }
  })
</script>
</body>
</html>